﻿using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Returns the top 10 trending topics for a specific WOEID, if trending information is available for it.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.TrendToolbox.bmp")]
    [Designer(typeof(GetTrendsListDesigner))]
    [Description("Returns the locations that Twitter has trending topic information for.")]
    public class GetTrendsList : TwitterOperationInvoker<List<TrendsResult>>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GetTrendsList"/> class.
        /// </summary>
        public GetTrendsList()
            : base("GetTrendsList")
        { }

        /// <summary>
        /// The Yahoo! Where On Earth ID of the location to return trending information for.
        /// Global information is available by using 1 as the WOEID.
        /// <remarks>
        /// Required Argument
        /// </remarks>
        /// </summary>
        /// <value>
        /// Where on Earth IDentifier
        /// </value>
        [Browsable(true)]
        [Category("Parameters")]
        [RequiredArgument]
        [Description("Where on Earth IDentifier")]
        public InArgument<int> WOEID { get; set; }

        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument woeidArgument = new RuntimeArgument("WOEID", typeof(int), ArgumentDirection.In, true);
            metadata.Bind(WOEID, woeidArgument);
            metadata.AddArgument(woeidArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("woeid", WOEID);

            base.Execute(context);
        }
    }
}
